﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Chapter3Applications.Models.Abstract;
using Chapter3Applications.Models.PersistentModel;

namespace Chapter3Applications.Models.Concrete
{
    public class ShoppingListRepository : IShoppingListRepository
    {
        private ShoppingListModelContainer context = new ShoppingListModelContainer();

        public IQueryable<Product> ProductSet 
        {
            get { return context.ProductSet.AsQueryable(); }
        }

        public void Add(Product product)
        {
            context.ProductSet.Add(product);
        }

        public void Remove(Product product)
        {
            context.ProductSet.Remove(product);
        }

        public IQueryable<ShoppingList> ShoppingListSet
        {
            get { return context.ShoppingListSet.AsQueryable(); }
        }

        public void Add(ShoppingList product)
        {
            context.ShoppingListSet.Add(product);
        }

        public void Remove(ShoppingList shoppingList)
        {
            context.ShoppingListSet.Remove(shoppingList);
        }

        public void SaveChanges()
        {
            context.SaveChanges();
        }
    }
}